<template>
    <div class="form-search">
        <label class="btn-nav-bg stripe-btn" @click="$router.push({
            path: '/'
        })">首页</label>
          <label class="btn-nav-bg stripe-btn" @click="$router.push({
            path: '/fenxi'
        })">对比分析</label>
        <el-dropdown @command="handleCommand">
            <div class="shishishuju">实时数据</div>
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item v-for="(item, idx) in huanliuList" :key="idx" :command="item.siteId">
                    {{ item.site }}
                </el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown>
             <label class="btn-nav-bg stripe-btn" @click="$router.push({
            path: '/alarmHistory'
        })">告警历史</label>
        <!-- <el-dropdown @command="handleCommandLishi">
            <div class="shishishuju">告警历史</div>
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item v-for="(item, idx) in huanliuList" :key="idx" :command="item.siteId">
                    {{ item.site }}
                </el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown> -->
      
    </div>
</template>

<script>
import { siteList } from "@/assets/data/index";

export default {
    name: "menueelement",
    components: {
    },

    data() {
        return {
            huanliuList: [], //换流站List
        };
    },
    mounted() {
        this.huanliuList = siteList;
    },

    methods: {
        handleCommand(id) {
            this.huanliuList.forEach(element => {
                sessionStorage.removeItem('kangbafuye');
                sessionStorage.removeItem('kangbafuye');
                if (element.siteId === id) {
                    if (element.site === '康巴换流站') {
                        this.$router.push({
                            path: "/kangba",
                            query: { siteId: element.siteId, site: element.site },
                        });
                    } else if (element.site === '阜康换流站') {
                        this.$router.push({
                            path: "/earlyWarning",
                            query: { siteId: element.siteId, site: element.site },
                        });
                    } else if (element.site === '中都换流站') {
                        this.$router.push({
                            path: "/zhongdu",
                            query: { siteId: element.siteId, site: element.site },
                        });
                    }

                }
            });
        },
        // 跳转历史数据页面
        handleCommandLishi(id) {
            this.huanliuList.forEach(element => {
                sessionStorage.removeItem('kangbafuye');
                sessionStorage.removeItem('kangbafuye');
                if (element.siteId === id) {
                    if (element.site === '康巴换流站') {
                        this.$router.push({
                            path: "/kangbaHistory",
                            query: { siteId: element.siteId, site: '康巴诺尔站' },
                        });
                    } else if (element.site === '阜康换流站') {
                        this.$router.push({
                            path: "/historyState",
                            query: { siteId: element.siteId, site: element.site },
                        });
                    } else if (element.site === '中都换流站') {
                        this.$router.push({
                            path: "/zhongduHistory",
                            query: { siteId: element.siteId, site: element.site },
                        });
                    }

                }
            });
        },
    },
};
</script>
<style scoped>
.el-dropdown-menu {
    background: #041a35 !important;

    border: 1px solid #40e5f0 !important;

    .el-dropdown-menu__item {
        color: rgba(255, 255, 255, 0.7);
        padding: 0;
        padding: 0 20px;

        p {
            padding: 0 20px;
        }

        &:not(.is-disabled):hover {
            color: #FFFFFF;
            background-color: #00aeff;
        }
    }
}
</style>

<style scoped lang="less">
.changzhan {
    color: aliceblue;
    margin-right: 10px;
}

.form-search {
    display: flex;
    align-items: center;
}

.shishishuju {
    //display: inline-block;
    //height: 28px;
    //line-height: 28px;
    //width: 195px;
    //text-align: center;
    padding: 1px 20px !important;
    //line-height: 51px;
    font-size: 18px;
    color: #fff;
    background: #247382;
    border: 1px solid #247382;
    border-radius: 4px;
    margin-left: 10px;
    height: 30px !important;
    line-height: 30px !important;
    //line-height: 30px !important;
    //background-position: -350px -65px;
    //font-weight: 700;
    cursor: pointer;
    font-family: SourceHanSansCN;
}

.shishishuju:focus,
.shishishuju:hover {
    background-color: #41596f;
    border-color: #41596f;
}
</style>